﻿using System;
using System.ServiceModel;

namespace BizElements.BusinessLayer
{
    /// <summary>Executes remote method calls on received objects.</summary>
    [ServiceContract(ConfigurationName = "BizElements.BusinessLayer.IMethodReceiverService")]
    public interface IMethodReceiverService
    {
        /// <summary>Invokes a generic method.</summary>
        /// <param name="serializedBusinessObject">Binary serialized object whose definition (class) contains the specified method.</param>
        /// <param name="methodName">Method to be executed.</param>
        /// <param name="serializedMethodParameters">Binary serialized method parameters.</param>
        /// <returns>Changed object serialized with binary formatter.</returns>
        [OperationContract]
        byte[] InvokeMethod(ref byte[] serializedBusinessObject, string methodName, byte[][] serializedMethodParameters);

        /// <summary>Invokes a generic static method.</summary>
        /// <param name="serializedType">Binary serialized type which contains the specified static method.</param>
        /// <param name="methodName">Method to be executed.</param>
        /// <param name="serializedMethodParameters">Binary serialized method parameters.</param>
        /// <returns>Method's return value serialized with binary formatter.</returns>
        [OperationContract]
        byte[] InvokeStaticMethod(byte[] serializedType, string methodName, byte[][] serializedMethodParameters);

        /// <summary>Invokes a method.</summary>
        /// <param name="serializedBusinessObject">Binary serialized object whose definition (class) contains the specified method.</param>
        /// <param name="methodName">Method to be executed.</param>
        /// <param name="serializedMethodParameters">Binary serialized method parameters.</param>
        /// <returns>Changed object serialized with binary formatter.</returns>
        [OperationContract]
        byte[] InvokeGenericMethod(ref byte[] serializedBusinessObject, string methodName, byte[][] serializedMethodParameters);

        /// <summary>Invokes a static method.</summary>
        /// <param name="serializedType">Binary serialized type which contains the specified static method.</param>
        /// <param name="methodName">Method to be executed.</param>
        /// <param name="serializedMethodParameters">Binary serialized method parameters.</param>
        /// <returns>Method's return value serialized with binary formatter.</returns>
        [OperationContract]
        byte[] InvokeGenericStaticMethod(byte[] serializedType, string methodName, byte[][] serializedMethodParameters);        
    }
}
